home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / komercni software / miton / SystemMechanic7Pro.exe / {app} / smhtml.dll / 1033 / HTML / LIBRARY.JS < prev    next >
Text File  |  2008-01-24  |  15KB  |  605 lines

  1. var language = 'english';
  2. //var language = 'french';
  3.  
  4. // called by the host application to initialize the
  5. // language variable during window.onload
  6. function SetLanguageVariable(_language)
  7. {
  8.    language = _language;
  9.    //alert(language);
  10. }
  11.  
  12. // helper function to trigger the host applications
  13. // OnWindowLoad event
  14. function CallExternalOnWindowLoad()
  15. {
  16.    try
  17.    {
  18.       external.DoOnWindowLoad();
  19.    }
  20.    catch(e)
  21.    {
  22.    }
  23. }
  24.  
  25. window.onresize = function() {
  26.   scaleDiv();
  27.   scaleDivTools();
  28.  
  29.   //scaleDivTools() ;
  30. };
  31.  
  32. window.onscroll = function() 
  33. {
  34.   scaleDiv();
  35. };
  36.  
  37. window.onload = function() 
  38. {
  39.     
  40.   CallExternalOnWindowLoad();
  41.   SetLanguageFile();
  42.  
  43.   scaleDiv();
  44.   document.body.onselectstart = function () 
  45.   {
  46.    return false;
  47.   }
  48.  
  49.   document.body.ondragstart = function () {
  50.      return false;
  51.    }
  52. };
  53.  
  54. function SetLanguageFile()
  55. {
  56.  var newjs=document.createElement('script');
  57.   newjs.type='text/javascript';
  58.         switch (language)
  59.         {
  60.         
  61.         
  62.             case 'english':
  63.             //alert(language);
  64.              newjs.src='english.js';
  65.             break
  66.             case 'french':
  67.             //alert(language);
  68.              newjs.src='french.js';
  69.  
  70.             break
  71.             default:
  72.             //alert(language);
  73.         }
  74.   document.getElementsByTagName('head')[0].appendChild(newjs);
  75.   try
  76.   {
  77.    
  78.     SetLanguage(language);
  79.   
  80.   }catch(e)
  81.   {
  82.     //alert('No SetLanguage function, or id not found');
  83.   }
  84.   
  85. }
  86.  
  87.  
  88. // Add functions to window.onload 
  89. function AddLoadEvent(func) {
  90.   var oldonload = window.onload;
  91.   if (typeof window.onload != 'function') {
  92.     window.onload = func;
  93.   } else {
  94.     window.onload = function() {
  95.       if (oldonload) {
  96.         oldonload();
  97.       }
  98.       func();
  99.     }
  100.   }
  101. }
  102.  
  103.  
  104. function GrayOut(vis, options) {
  105.   // Pass true to gray out screen, false to ungray
  106.   // options are optional.  This is a JSON object with the following (optional) properties
  107.   // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  108.   // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  109.   // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  110.   // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  111.   // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  112.   // in any order.  Pass only the properties you need to set.
  113.   var darkDivId = 'dimmer';
  114.   var options = options || {}; 
  115.   var zindex = options.zindex || 50;
  116.   var opacity = options.opacity || 80;
  117.   var opaque = (opacity / 80);
  118.   var bgcolor = options.bgcolor ||  '#404040';
  119.   var dark=document.getElementById(darkDivId);
  120.   if (!dark) {
  121.     // The dark layer doesn't exist, it's never been created.  So we'll
  122.     // create it here and apply some basic styles.
  123.     // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
  124.     var tbody = document.getElementsByTagName("body")[0];
  125.     var tnode = document.createElement('div');           // Create the layer.
  126.         tnode.style.position='absolute';                 // Position absolutely
  127.         tnode.style.top='0px';                           // In the top
  128.         tnode.style.left='0px';                          // Left corner of the page
  129.         tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
  130.         tnode.style.display='none';                      // Start out Hidden
  131.         tnode.id=darkDivId;                   // Name it so we can find it later
  132.     tbody.appendChild(tnode);                            // Add it to the web page
  133.     dark=document.getElementById(darkDivId);  // Get the object.
  134.   }
  135.   if (vis) {
  136.   
  137.   
  138.     //alert(GetScrollTop());
  139.     //alert(screen.height +  " " +  document.body.scrollHeight + " " + document.body.offsetHeight );
  140.     
  141.     // Calculate the page width and height 
  142.     if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
  143.         var pageWidth = document.body.scrollWidth+'px';
  144.         var pageHeight = document.body.scrollHeight+'px';
  145.     } 
  146.     else if( document.body.offsetWidth ) {
  147.       var pageWidth = document.body.offsetWidth+'px';
  148.       var pageHeight = document.body.offsetHeight+'px';
  149.     } else {
  150.        var pageWidth='100%';
  151.        var pageHeight='100%';
  152.     }   
  153.     //set the shader to cover the entire page and make it visible.
  154.     dark.style.opacity=opaque;                      
  155.     dark.style.MozOpacity=opaque;                   
  156.     dark.style.filter='alpha(opacity='+opacity+')'; 
  157.     dark.style.zIndex=zindex;        
  158.     dark.style.backgroundColor=bgcolor;  
  159.     dark.style.width= '100%';
  160.     
  161. //    if(document.body.scrollHeight> 300)
  162. //    {
  163. //      dark.style.height= pageHeight;
  164. //    }else
  165. //    {
  166. //      dark.style.height= '100%';
  167. //    }
  168.     
  169.     dark.style.height= document.documentElement.clientHeight;
  170.     
  171.     
  172.     dark.style.display='block';        
  173.     //document.body.style.scrollbarBaseColor = '#404040';
  174.     
  175.     //document.body.className = "body_gray_scrollbar";
  176.     document.documentElement.className = "body_gray_scrollbar";
  177.     
  178.     document.body.style.scrolling = 'no';
  179.     
  180.     scaleDiv();
  181.   } else {
  182.      dark.style.display='none';
  183.     //document.body.style.scrollbarBaseColor = '';
  184.     document.body.style.scrolling = 'auto';
  185.     //document.body.className = "";
  186.     document.documentElement.className = "";
  187.     
  188.     
  189.     
  190.      
  191.   }
  192. }
  193.  
  194.  
  195.  
  196.  
  197.  
  198. function GetScrollTop()
  199. {
  200.  var theTop = 0;
  201.  if (document.documentElement && document.documentElement.scrollTop)
  202.       theTop = document.documentElement.scrollTop;
  203.  else if (document.body)
  204.       theTop = document.body.scrollTop
  205.  return theTop;
  206. }
  207.  
  208.  
  209. // This function begins the animation of the panel element by setting the height
  210. // to 1 pixel and setting the other animation properties. The return value is the
  211. // starting height of the panel to be used by the display element's internal
  212. // height tracking mechanism.
  213. function Animate_BeginAnimation(panelId)
  214. {
  215.   var panel = document.getElementById(panelId);
  216.   
  217.   Animate_SetPanelHeight(panelId, 1);
  218.  
  219.   panel.style.overflow = "hidden";
  220.   panel.style.display = "block";
  221.   
  222.   return 1;
  223. }
  224.  
  225. // This function ends the animation of the panel element by setting the overflow
  226. // of the panel to visible to ensure the panel makes it to it's correct height. The
  227. // return value of this function is the current height of the panel.
  228. function Animate_EndAnimation(panelId)
  229. {
  230.   var panel = document.getElementById(panelId);
  231.   
  232.   panel.style.overflow = "visible";
  233.   return panel.offsetHeight;
  234. }
  235.  
  236. function Animate_SetPanelHeight(panelId, height)
  237. {
  238.   var panel = document.getElementById(panelId);
  239.   panel.style.height = height + "px";
  240. }
  241.  
  242. function Get(id)
  243. {
  244.   return document.getElementById(id);
  245. }
  246.  
  247. function SetClass(id, className)
  248. {
  249.   var element = document.getElementById(id);
  250.   element.className = className;
  251. }
  252.  
  253. function SetDisplay(id, display)
  254. {
  255.   var element = document.getElementById(id);
  256.   element.style.display = display;
  257. }
  258.  
  259. // id : id of the control
  260. // value : boolean (true/ false )
  261. // UseBlock : bool ,  use  block to display
  262. function SetDisplayWidget( id , value, UseBlock )
  263. {
  264.   var type =  UseBlock ? "block" : "inline"; 
  265.   if ( value )
  266.    Get(id).style.display = type;
  267.   else
  268.    Get(id).style.display = "none";
  269. }
  270.  
  271. // id : id of the control
  272. // value : boolean (true/ false )
  273. function SetVisibility( id , value )
  274. {
  275.   if ( value )
  276.    Get(id).style.visibility = "visible";
  277.   else
  278.    Get(id).style.visibility = "hidden";
  279. }
  280.  
  281.  
  282.  
  283. function ToggleDisplay(id)
  284. {
  285.   var element = document.getElementById(id);
  286.   
  287.   if (element.style.display == "none")
  288.     element.style.display = "block";
  289.   else
  290.     element.style.display = "none";
  291. }
  292.  
  293.  
  294. function ToggleWidget(divid , imgid)
  295. {
  296.   var imgmax = "maximize.gif";
  297.   var imgmin = "minimize.gif";
  298.   
  299.   var img = document.getElementById(imgid);
  300.  
  301.   var element = document.getElementById(divid);
  302.   
  303.   if (element.style.display == "none")
  304.   {
  305.     element.style.display = "block";
  306.     img.src = imgmin;
  307.   }
  308.   else
  309.   {
  310.     element.style.display = "none";
  311.     img.src = imgmax;
  312.   }
  313. }
  314. function ToggleWidgetChild(id , imgid)
  315. {
  316.   var imgmax = "plus.gif";
  317.   var imgmin = "minus.gif";
  318.   
  319.   var img = document.getElementById(imgid);
  320.  
  321.   var element = document.getElementById(id);
  322.   
  323.   if (element.style.display == "none")
  324.   {
  325.     element.style.display = "block";
  326.     img.src = imgmin;
  327.   }
  328.   else
  329.   {
  330.     element.style.display = "none";
  331.     img.src = imgmax;
  332.   }
  333. }
  334.  
  335.  
  336. var  ns4 = (document.layers)? true:false;
  337. var ie4 = (document.all)? true:false;
  338.  
  339. function findPosX(id)
  340.   {
  341.   
  342.   var obj = document.getElementById(id);
  343.   
  344.     var curleft = 0;
  345.     if(obj.offsetParent)
  346.         while(1) 
  347.         {
  348.           curleft += obj.offsetLeft;
  349.           if(!obj.offsetParent)
  350.             break;
  351.           obj = obj.offsetParent;
  352.         }
  353.     else if(obj.x)
  354.         curleft += obj.x;
  355.     return curleft;
  356.   }
  357.  
  358.   function findPosY(id)
  359.   {
  360.    var obj = document.getElementById(id);
  361.     var curtop = 0;
  362.     if(obj.offsetParent)
  363.         while(1)
  364.         {
  365.           curtop += obj.offsetTop;
  366.           if(!obj.offsetParent)
  367.             break;
  368.           obj = obj.offsetParent;
  369.         }
  370.     else if(obj.y)
  371.         curtop += obj.y;
  372.     return curtop;
  373.   }
  374.   
  375.   
  376.   
  377.   
  378.   
  379. function URLEncode(text )
  380. {
  381.     // The Javascript escape and unescape functions do not correspond
  382.     // with what browsers actually do...
  383.     var SAFECHARS = "0123456789" +                    // Numeric
  384.                     "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +    // Alphabetic
  385.                     "abcdefghijklmnopqrstuvwxyz" +
  386.                     "-_.!~*'()";                    // RFC2396 Mark characters
  387.     var HEX = "0123456789ABCDEF";
  388.  
  389.     var plaintext = text;
  390.     var encoded = "";
  391.     for (var i = 0; i < plaintext.length; i++ ) {
  392.         var ch = plaintext.charAt(i);
  393.         if (ch == " ") {
  394.             encoded += "+";                // x-www-urlencoded, rather than %20
  395.         } else if (SAFECHARS.indexOf(ch) != -1) {
  396.             encoded += ch;
  397.         } else {
  398.             var charCode = ch.charCodeAt(0);
  399.             if (charCode > 255) {
  400.                 alert( "Unicode Character '" 
  401.                         + ch 
  402.                         + "' cannot be encoded using standard URL encoding.\n" +
  403.                           "(URL encoding only supports 8-bit characters.)\n" +
  404.                           "A space (+) will be substituted." );
  405.                 encoded += "+";
  406.             } else {
  407.                 encoded += "%";
  408.                 encoded += HEX.charAt((charCode >> 4) & 0xF);
  409.                 encoded += HEX.charAt(charCode & 0xF);
  410.             }
  411.         }
  412.     } // for
  413.  
  414. return encoded;
  415. //    document.URLForm.F2.value = encoded;
  416. //    return false;
  417. }
  418.  
  419. function URLDecode( text )
  420. {
  421.    // Replace + with ' '
  422.    // Replace %xx with equivalent character
  423.    // Put [ERROR] in output if %xx is invalid.
  424.    var HEXCHARS = "0123456789ABCDEFabcdef"; 
  425.    //var encoded = document.URLForm.F2.value;
  426.    var encoded = text;
  427.    var plaintext = "";
  428.    var i = 0;
  429.    while (i < encoded.length) {
  430.        var ch = encoded.charAt(i);
  431.        if (ch == "+") {
  432.            plaintext += " ";
  433.            i++;
  434.        } else if (ch == "%") {
  435.             if (i < (encoded.length-2) 
  436.                     && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
  437.                     && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
  438.                 plaintext += unescape( encoded.substr(i,3) );
  439.                 i += 3;
  440.             } else {
  441.                 alert( 'Bad escape combination near ...' + encoded.substr(i) );
  442.                 plaintext += "%[ERROR]";
  443.                 i++;
  444.             }
  445.         } else {
  446.            plaintext += ch;
  447.            i++;
  448.         }
  449.     } // while
  450.     
  451.     return plaintext;
  452. //   document.URLForm.F1.value = plaintext;
  453. //   return false;
  454. };
  455.  
  456.  
  457. function moveDiv(div, x , y)
  458. {
  459.   var o = Get(div);
  460.   o.style.left = x;
  461.   o.style.top = y;
  462. }
  463.  
  464.  
  465.  
  466.  
  467. //***************  Gray out Functions **********************************
  468.  
  469. //
  470. // global variables
  471. //
  472. //var isMozilla;
  473. var objDiv = null;
  474. var originalDivHTML = "";
  475. var DivID = "";
  476. var over = false;
  477.  
  478. //
  479. // dinamically add a div to 
  480. // dim all the page
  481. //
  482. function buildDimmerDiv()
  483. {
  484. //    document.write('<div id="dimmer" class="dimmer" style="width:'+ window.screen.width + 'px; height:' + window.screen.height +'px"></div>');
  485.     
  486.     document.write('<div id="dimmer" class="dimmer" style="width:100%; height:100%;  "></div>');
  487.     
  488. }
  489.  
  490. function init()
  491. {
  492.     // check browser
  493.     ///isMozilla = (document.all) ? 0 : 1;
  494.     //if (isMozilla) 
  495.     //{
  496.         //document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
  497.     //}
  498.  
  499.     //document.onmousedown = MouseDown;
  500.    // document.onmousemove = MouseMove;
  501.     //document.onmouseup = MouseUp;
  502.  
  503.     // add the div
  504.     // used to dim the page
  505. buildDimmerDiv();
  506.  
  507. }
  508.  
  509. // call init
  510. //init();
  511.  
  512.  
  513.  function GrayOut1(value)
  514. {
  515.     if(!value)
  516.     {
  517.      document.body.style.scrollbarBaseColor = ''; 
  518.     document.documentElement.scrollbarBaseColor = '';
  519.        document.getElementById('dimmer').style.visibility = "hidden";
  520.        //document.getElementById('dimmer').style.dislpay = "none";
  521.        
  522.       }
  523.       else
  524.       {
  525.        document.body.style.scrollbarBaseColor = '#404040';
  526.      document.documentElement.scrollbarBaseColor = '#404040';
  527.        document.getElementById('dimmer').style.visibility = "visible";
  528.       // document.getElementById('dimmer').style.dislpay = "block";
  529.       }
  530.       
  531.       scaleDiv() ;
  532. }
  533.  
  534.  
  535. function scaleDiv1() {
  536.   if (document.getElementById("dimmer") != null)
  537.   {
  538.     var scrollDiv = document.getElementById("dimmer");
  539.  
  540.     //
  541.     //alert(scrollDiv.style.visibility );
  542.     
  543.     if( scrollDiv.style.visibility != 'visible')
  544.        return;
  545.     
  546.     
  547.      
  548.   
  549.     var scalePercent = 0.80;//0.82
  550.     var wHeight  = document.body.offsetHeight;
  551.    // var wHeight  =document.documentElement.clientHeight;
  552.     
  553.     if ( (wHeight > 600) && (wHeight < 900) )
  554.     {
  555.       scalePercent = 0.86;//0.86
  556.     } 
  557.     else if ( wHeight > 900 )
  558.     {
  559.       scalePercent = 0.90;
  560.     }
  561.     
  562.     
  563.     
  564.     
  565.    //alert(wHeight);
  566.  
  567.     scrollDiv.style.height = wHeight; // GetScrollTop();// wHeight * scalePercent;
  568.   }
  569. }
  570.  
  571.  
  572.  
  573. function scaleDiv() 
  574. {
  575.   if (document.getElementById("dimmer") != null)
  576.   {
  577.     var wHeight  = document.documentElement.offsetHeight;
  578.     var wWidth  = document.documentElement.offsetWidth;
  579.     var scrollDiv = document.getElementById("dimmer");
  580.     
  581.     scrollDiv.style.height = wHeight + GetScrollTop();
  582.     scrollDiv.style.width = wWidth;
  583.   }
  584. }
  585.  
  586. function scaleDivTools() 
  587. {
  588.   if (document.getElementById("divChildTools_nav") != null)
  589.   {
  590.     var wHeight  = document.documentElement.offsetHeight;
  591.     var scrollDiv = document.getElementById("divChildTools_nav");
  592.  
  593.     scrollDiv.style.height = wHeight -  72;
  594.  
  595.   }    
  596. }
  597.  
  598. //***************  Gray out Functions **********************************
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.